# -*- coding: utf-8 -*-
from utils.operators.spark_submit import SparkSubmitOperator
from airflow.operators.bash import BashOperator
from jms.dm import jms_dm__dm_cn_sham_deliver_goods_dt

export__sham_deliver_goods = SparkSubmitOperator(
    task_id='export__sham_deliver_goods',
    pool_slots=5,
    # depends_on_past=True,  # 如果任务依赖于前一天的同名任务，则将 depends_on_past 设为 True
    # task_concurrency=1,  # 如果任务不支持并发，则将 task_concurrency 设为 1
    name='export__sham_deliver_goods_{{ execution_date | date_add(-1) | cst_ds }}',  # yarn 任务名称
    driver_memory='4G',
    executor_memory='8G',
    executor_cores=5,
    num_executors=8,
    email=['zhangqinglin@jtexpress.com','yl_bigdata@yl-scm.com'],
    conf={'spark.executor.memoryOverhead': 2048,
          'spark.core.connection.ack.wait.timeout': 3000,
          'spark.default.parallelism': 600,
          'spark.locality.wait': 60,
          },
    java_class='com.yunlu.bigdata.jobs.export.ExportShamDeliverGoods2HDFS',  # spark 主类
    # application='hdfs:///user/spark/work/dm/lyx/pro_aging_data_t2/jobs-1.0-SNAPSHOT-jar-with-dependencies.jar',  # spark jar 包
    application='hdfs:///scheduler/jms/spark/lyx/sham_deliver_goods/jobs-1.0-SNAPSHOT-jar-with-dependencies.jar',
    # spark jar 包
    application_args=['{{ execution_date  | date_add(-1) | cst_ds }}', '{{ execution_date  | date_add(-1) | cst_ds }}'],
    # 参数dt 2020-10-26
)

upload__sham_deliver_goods = BashOperator(
    task_id="upload__sham_deliver_goods",
    email=['zhangqinglin@jtexpress.com','yl_bigdata@yl-scm.com'],
    pool='unlimited_pool',
    bash_command='jms/oss/sham_deliver_goods/upload_sham_deliver_goods.sh',
)

# 设置依赖
upload__sham_deliver_goods << export__sham_deliver_goods << jms_dm__dm_cn_sham_deliver_goods_dt
